﻿using System;

namespace HW-2
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入数组长度:");
            int n = int.Parse(Console.ReadLine());
            if (n < 1)
                Console.WriteLine("非法的长度输入");
            else {
                int[] nums= new int[n];
            for(int index = 0; index<n; index++) {
                    Console.WriteLine("请输入第{0}个数", index+1);
            string num = Console.ReadLine();
            int a = int.Parse(num);
                    nums[index]=a;
            }
            func(nums);
            }
        }

        static void func(int[] n)
        {
            int sum = 0, min = 100000, max = -100000;
            for (int i = 0; i < n.Length; i++)
            {
                sum += n[i];
                if (n[i] < min)
                    min = n[i];
                if (n[i] > max)
                    max = n[i];
            }
            double average = sum / (n.Length * 1.0);
            Console.WriteLine("最大值:");
            Console.WriteLine(max);
            Console.WriteLine("最小值:");
            Console.WriteLine(min);
            Console.WriteLine("求和:");
            Console.WriteLine(sum);
            Console.WriteLine("平均数:");
            Console.WriteLine(average);
        }
    }
}

